//
//  JMToken.m
//  jiMuOperate
//
//  Created by 胡梅方 on 16/4/25.
//  Copyright © 2016年 jinXinFengLi. All rights reserved.
//

#import "JMToken.h"

@implementation JMToken
+(void)requestTokenWithDict:(NSDictionary*)dictRe Success:(void(^)(NSData *data))success Error:(void(^)(NSString *errorStr))error;

{
    
    NSString *strM = [JMData stringWithDict:dictRe];
    NSArray *array = @[strM,JMURLToken];
    
    [Request startRequestWithArray:array FinishedBlock:^(NSData *data) {
        //s是否删除
        [MBProgressHUD hideHUD];
        
        NSDictionary *dict = [JMData dictAndTestData:data];
        if (dict == nil) {
            SHOWALERT(@"登录失败");
            return ;
        }
//        UserEntity *user = [UserEntity shardUserInfo];
//        [UserEntity clearAllData];
//        [user setValuesForKeysWithDictionary:dict];
//        if(user.error){
//            SHOWALERT(user.error_description);
//            if (error) {
//                error(user.error_description);
//            }
//            /*
//             //回登录
//             if (![viewC isKindOfClass:[ZDTableVController class]]) {
//             ZDTableVController *tabVc = [[ZDTableVController alloc]init];
//             [viewC presentViewController:tabVc animated:YES completion:nil];
//             }
//             */
//            return;
//        }
#define 登录要加这个
//        if (dictRe.keyValues.count >1) {
//            user.loginOrNO = YES;
//        }
//        //设置令牌过期时间
//        NSDate *expires_on = [NSDate dateWithTimeIntervalSinceNow:[user.expires_in longLongValue] - 120];
//        user.expires_on = expires_on;
        
        if (success) {
            success((NSData *)data);
        }
        /*
         if ([viewC isKindOfClass:[ZDTableVController class]]) {
         ZDHomeViewController *homeVC = [[ZDHomeViewController alloc]init];
         YTNavigationController *nav = [[YTNavigationController alloc]initWithRootViewController:homeVC];
         [viewC presentViewController:nav animated:YES completion:nil];
         }else{
         [AddressInfo requestAddressList];
         }
         */
        
    } FailBlock:^(NSString *string) {
        if (error) {
            error(string);
        }
        [MBProgressHUD hideHUD];
        [MBProgressHUD showError:@"服务器异常"];
    }];

    
    
    
    
    
}
@end
